package com.servlet;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Discription:
 */
public class Servlet1 extends HttpServlet {
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String username = request.getParameter("username");//获取请求的参数（办事的材料）
        System.out.println("在Servlet1（柜台1）中查看参数"+username);

        //给材料盖一个章，并传递到servlet2（柜台2）中查看
        request.setAttribute("key","柜台1的章");

        //问路：Servlet2（柜台2）怎么走
        /*
            请求转发必须要以斜杠打头，斜杠表示地址为：http://ip:/port/工程名/   映射到idea代码的web目录

         */
        RequestDispatcher requestDispatcher = request.getRequestDispatcher("/servlet2");

        //走向Servlet2（柜台2）
        requestDispatcher.forward(request,response);
    }
}
